package com.sun.sort.insert;

import java.util.Arrays;

public class insert2 {
    public static void main(String[] args) {
        int[] arr = {101,34,119,-1,2,1};
        for (int i = 1; i < arr.length; i++) {
            int index = i - 1;
            int indexV = arr[i];
            while (index >= 0 && indexV < arr[index]){
                arr[index + 1] = arr[index];
                index--;
            }
            arr[index + 1] = indexV;
        }
        System.out.println(Arrays.toString(arr));
    }
}
